package com.zy.project.system.menu.controller;

import com.zy.core.common.utils.StringUtils;
import com.zy.core.data.jpa.support.entity.page.Pagination;
import com.zy.core.util.page.LayuiPageResult;
import com.zy.core.util.page.Result;
import com.zy.core.util.servlet.ServletUtils;
import com.zy.core.web.BaseController;
import com.zy.core.web.entity.JsonResult;
import com.zy.project.system.menu.manager.SystemMenuManager;
import com.zy.project.system.online.manager.UserOnlineManager;
import com.zy.project.system.permission.entity.SystemPermission;
import com.zy.project.system.permission.manager.SystemPermissionManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;

/**
 * 控制器
 */
@Controller
@RequestMapping("/system/menu")
@Api(description = "系统菜单接口")
public class SystemMenuController extends BaseController {

    private static final Logger logger = LoggerFactory.getLogger(SystemMenuController.class);

    private static final String BASE_URL = "system/menu/";


    @Autowired
    private SystemMenuManager menuManager;


    @GetMapping("/index")
    @ApiIgnore
    public String index(HttpServletRequest request, HttpServletResponse response, ModelMap model){

        return BASE_URL + "index";
    }

    @GetMapping("/add")
    @ApiIgnore
    public String add(HttpServletRequest request, HttpServletResponse response, ModelMap model){
        return BASE_URL + "add";
    }

    @GetMapping("/edit/{id}")
    @ApiIgnore
    public String edit(HttpServletRequest request, HttpServletResponse response, ModelMap model,
                       @PathVariable("id") String id){
        if(StringUtils.isNotEmpty(id)){
            model.put("menu",menuManager.findById(id));
        }
        return BASE_URL + "edit";
    }

    @GetMapping("/view/{id}")
    @ApiIgnore
    public String view(HttpServletRequest request, HttpServletResponse response, ModelMap model,
                       @PathVariable("id") String id){
        if(StringUtils.isNotEmpty(id)){
            model.put("menu",menuManager.findById(id));
        }
        return BASE_URL + "view";
    }

    /**
     * 获取列表数据
     * @param request
     * @param response
     * @param model
     * @param page 页码
     * @param limit 每页数据量
     */
    @GetMapping
    @ApiIgnore
    public void list(HttpServletRequest request, HttpServletResponse response, ModelMap model,
                       @RequestParam(value = "page", required = true) int page,
                       @RequestParam(value = "limit", required = true) int limit){

    }

    /**
     * 执行删除
     * @param request
     * @param response
     * @param ids
     */
    @DeleteMapping
    public void delete(HttpServletRequest request, HttpServletResponse response,String[] ids){

    }

    /**
     * 执行更新
     * @param request
     * @param response
     * @param permission
     */
    @PutMapping
    public void update(HttpServletRequest request, HttpServletResponse response, SystemPermission permission){

    }

    /**
     * 新增
     * @param request
     * @param response
     * @return
     */
    @PostMapping
    @ApiOperation(value = "新增菜单")
    public void save(HttpServletRequest request, HttpServletResponse response){

    }


}
